package cn.tpshion.pulsar.support;

import lombok.Data;
import org.apache.pulsar.client.api.Schema;

@Data
public class PulsarProducer {

    public static final String PERSISTENT = "persistent";

    private Schema schema = Schema.STRING;
    private PulsarProperties.TopicSchema topicSchema = PulsarProperties.TopicSchema.STRING;
    private String topic;
    private String producerName;
    private String namespace;
    private String tenant;
    private int sendTimeoutMs = 30000;
    private boolean blockIfQueueFull = false;
    private int maxPendingMessages = 1000;
    private int batchingMaxMessages = 1000;
    private boolean batchingEnabled = true;
    private boolean chunkingEnabled = false;

    public String buildTopic(){
        return PERSISTENT + "://" + tenant + "/" + namespace + "/" + topic;
    }

    public void setTopicSchema(PulsarProperties.TopicSchema topicSchema) {
        this.topicSchema = topicSchema;
        this.schema = topicSchema.getSchema();
    }

}
